<?php
/**
 * @Copyright Copyright (C) 2010-2012
 * @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
 + Created by:          Webit Solution
 * Company:		Webit Solution
 + Contact:		www.webits.asia, developer@webits.asia
 * Created on:	May 17, 2010
 ^
 + Project: 		WRecruit
 * File Name:	views/employer/tmpl/mydepartments.php
 ^
 * Description: template view for my departments
 ^
 * History:		NONE
 ^
 */

 
 defined('_JEXEC') or die('Restricted access');
 
 global $mainframe;
 $document =& JFactory::getDocument();
 $document->addStyleSheet('components/com_wrecruit/css/'.$this->config['theme']);

 ?>
<?php if ($this->config['offline'] == '1'){ ?>
<table cellpadding="0" cellspacing="0" border="0" width="100%" >
	<tr><td valign="top" class="<?php echo $this->theme['title']; ?>" >	<?php echo $this->config['title']; ?></td></tr>
	<tr><td height="25"></td></tr>
	<tr><td class="wrecruitmsg">
		<?php echo $this->config['offline_text']; ?>
	</td></tr>
</table>	
<?php }else{ ?>

<table cellpadding="0" cellspacing="0" border="0" width="100%" >
	<tr><td valign="top" class="<?php echo $this->theme['title']; ?>" >	
		<?php echo $this->config['title']; ?>
	</td>
	</tr>
	<tr><td height="23"></td></tr>
	<?php if ($this->config['cur_location'] == 1) {?>
	<tr><td height="0"></td></tr>
	<tr><td class="curloc">
		<?php echo JText::_('JS_CUR_LOC'); ?> : <?php echo JText::_('JS_MY_DEPARTMENTS'); ?>
	</td></tr>
	<?php } ?>
	<tr><td>
		<?php 
			$cutomlink = 'index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=formdepartment&Itemid='.$this->Itemid;
			$cutomlinktext = JText::_('JS_NEW_DEPARTMENT');
			$count = 0;
			if (sizeof($this->employerlinks) != 0){
				echo '<div id="toplinks"><ul>';
				
				foreach($this->employerlinks as $lnk)	{ 
				 if ($this->config['tmenu_emnewdepartment'] == 1) {
					if ($count == 1) { ?>
						<span>
							<a href="<?php echo $cutomlink; ?>"> <?php echo $cutomlinktext; ?></a>
						</span>
					<?php }	?>
					<?php }	?>
					<span <?php if($lnk[2] == 1)echo 'class="first"'; elseif($lnk[2] == -1)echo 'class="last"';  ?>>
						<a href="<?php echo $lnk[0]; ?>"> <?php echo $lnk[1]; ?></a>
					</span>
				<?php $count++;	
				}
				echo '<ul></div>';			
			} 
		?>
	</td></tr>	
	<tr><td height="3"></td></tr>
	<tr><td class="<?php echo $this->theme['heading']; ?>" align="center">
		<?php echo JText::_('JS_MY_DEPARTMENTS'); ?>
	</td></tr>
	<tr><td height="3"></td></tr>
</table>


<?php
if ($this->departments){

if ($this->userrole->rolefor == 1) { // employer


?>
<form action="index.php" method="post" name="adminForm">
	<table cellpadding="0" cellspacing="0" border="0" width="100%" >
		<tr  class="<?php echo $this->theme['sortlinks']; ?>" valign="middle">
			<td valign="center" class="<?php echo $this->theme['sortlinks']; ?>" align="left" > 
				<strong>&nbsp;<?php echo JText::_('JS_NAME'); ?></strong>
			</td>
			<td valign="center" class="<?php echo $this->theme['sortlinks']; ?>" align="left" > 
				<strong><?php echo JText::_('JS_COMPANY'); ?></strong>
			</td>
			<td width="30"><strong><?php echo JText::_('JS_STATUS'); ?></strong></td>
			<td width="30"></td>
			<td width="20"></td>
			<td width="30"></td>
			<td width="30"></td>
		</tr>
		
		<?php 
		
		$tdclass = array($this->theme['odd'], $this->theme['even']);
		$isodd =1;
		foreach($this->departments as $department)	{ 
			$isodd = 1 - $isodd; 
			?>
			<tr class="<?php echo $tdclass[$isodd]; ?>"> 
						<td class="maintext">&nbsp;<?php echo $department->name;?></td>
						<td class="maintext"><?php echo $department->companyname; ?></td>
						<td class="maintext"><strong><?php if ($department->status == 1) echo JText::_('JS_APPROVED'); elseif ($department->status == 0) echo  JText::_('JS_PENDDING');  ?></strong></td>
						<td></td>
					<td class="maintext" align="center"><a href="index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=formdepartment&pd=<?php echo $department->id; ?>" title="<?php echo  JText::_('JS_EDIT');  ?>"><img width="15" height="15" src="components/com_wrecruit/images/edit.png" /></td>
					
					<td class="maintext" align="center" valign="middle">
							<a href="index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=view_department&vp=1&pd=<?php echo $department->id; ?>" title="<?php echo  JText::_('JS_VIEW');  ?>" >
								<img width="15" height="15" src="components/com_wrecruit/images/view.png" />
							</a>
					</td>
					<td class="maintext" align="center">
							<a href="index.php?option=com_wrecruit&c=wrecruit&task=deletedepartment&pd=<?php echo $department->id; ?>" title="<?php echo  JText::_('JS_DELETE');  ?>">
								<img width="15" height="15" src="components/com_wrecruit/images/delete.png" />
							</a>
							
					</td>
						
					</tr>
					
		<?php 
		}
		?>		
	</table>
			<input type="hidden" name="option" value="<?php echo $this->option; ?>" />
			<input type="hidden" name="task" value="deletedepartment" />
			<input type="hidden" id="id" name="id" value="" />

	</form>

<form action="<?php echo JRoute::_('index.php?option=com_wrecruit&c=wrecruit&view=employer&layout=mydepartments&Itemid='.$this->Itemid); ?>" method="post">
<table cellpadding="0" cellspacing="0" border="0" width="100%" >
    <tr>
        <td></td>
        <td >
            <?php
            echo $this->pagination->getPagesLinks();
            ?>
        </td>
    </tr>
    <tr>
        <td align="left">
            <?php echo JText::_('JS_DISPLAY_#'); ?>
            <?php
            echo $this->pagination->getLimitBox();
            ?>
        </td>
        <td align="right">
            <?php
            echo $this->pagination->getResultsCounter();
            ?>
        </td>
    </tr>
</table>
</form>	
<?php

} else{ // not allowed job posting
echo JText::_('JS_YOU_ARE_NOT_ALLOWED_TO_VIEW');
}	
}else{ // no result found in this category
	echo JText::_('JS_RESULT_NOT_FOUND');
}
}//ol
?>	
<div width="100%">
<?php 
if($this->config['fr_cr_txsh']) {
	echo 
	'<table width="100%" style="table-layout:fixed;">
		<tr><td height="15"></td></tr>
		<tr><td style="vertical-align:top;" align="center">'.$this->config['fr_cr_txa'].$this->config['fr_cr_txb'].'</td></tr>
	</table>';
}	
?>
</div>


